package com.example.pet.controller;

import com.example.pet.service.UserInfoService;
import com.hj.pet.model.ReturnT;
import com.hj.pet.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/userInfo")
public class UserInfoController {
    @Autowired
    UserInfoService userInfoService;

    @RequestMapping(value = "save",method = RequestMethod.POST)
    @ResponseBody
    public ReturnT<?> save(@RequestBody UserInfo userInfo){
        return userInfoService.save(userInfo);
    }

    @RequestMapping(value = "updateById",method = RequestMethod.POST)
    @ResponseBody
    public ReturnT<?> updateById(@RequestBody UserInfo userInfo){
        return userInfoService.updateById(userInfo);
    }

    @RequestMapping(value = "findUserById",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> findUserById(@RequestParam int userId){
        return userInfoService.findUserById(userId);
    }

    @RequestMapping(value = "findUserByAc",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> findUserByAc(@RequestParam String user_account){
        return userInfoService.findUserByAc(user_account);
    }

    @RequestMapping(value = "findUsersSeller",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> findUsersSeller(@RequestParam boolean is_seller){
        return userInfoService.findUsersSeller(is_seller);
    }

    @RequestMapping(value = "findUsersVip",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> findUsersVip(@RequestParam boolean is_vip){
        return userInfoService.findUsersVip(is_vip);
    }

    @RequestMapping(value = "delUserById",method = RequestMethod.DELETE)
    @ResponseBody
    public ReturnT<?> delUserById(@RequestParam int userId){
        return userInfoService.delUserById(userId);
    }

    @RequestMapping(value = "findUsers",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> findUsers(@RequestBody UserInfo userInfo){
        return userInfoService.findUsers(userInfo);
    }
}
